//
//  ViewController.swift
//  Scroller_swift
//
//  Created by CarlsonLee on 2020/4/22.
//  Copyright © 2020 CarlsonLee. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        initSubviews()
    }

    func initSubviews() {
        //图片轮播
        let rect1 = CGRect(x: 10, y: 200, width: view.bounds.size.width-20, height: 80)
        let scroller1 = ScrollerView(frame: rect1, type: .image, dir: .hor)
        view.addSubview(scroller1)
        
        let datas1 = ["http://image.ibuxing.com/header/1578455073169.gif", "http://image.ibuxing.com/header/1577788008541.gif", "http://image.ibuxing.com/header/1578455446249.gif"]
        scroller1.loadDatas(datas1)
        scroller1.callBack = {index in
            print("scroller1点击位置：\(index)")
        }
        
        //文字轮播
        let rect2 = CGRect(x: 10, y: 400, width: view.bounds.size.width-20, height: 40)
        let scroller2 = ScrollerView(frame: rect2, type: .text, dir: .ver)
        view.addSubview(scroller2)
        scroller2.setInterval(2)
        
        let datas2 = ["swift-这是一条轮播消息1111111", "swift-这是一条轮播消息22222222", "swift-这是一条轮播消息33333333", "swift-这是一条轮播消息44444444"]
        scroller2.loadDatas(datas2)
        scroller2.callBack = {index in
            print("scroller2点击位置：\(index)")
        }
    }
}

